<%@ include file="IsProff.jsp"%>
<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*,database.*" %>

<%
try{
DBCon db1 = new DBCon();
int sizeOfP = db1.countProjects(",professor where professor.id = project.professorid and status <> 'uncomplete'");
ResultSet res2 = db1.getProject(",professor where professor.id = project.professorid and status <> 'uncomplete'");
String [] ids = new String[sizeOfP];
String [] titles = new String[sizeOfP];
String[] status= new String[sizeOfP];
String[] profName= new String[sizeOfP];
for(int i=0;res2.next();i++)
 {
    ids[i] = res2.getString("id");
    titles[i] = res2.getString("title");
    status[i] = res2.getString("status");
	profName[i] = res2.getString("firstName")+" "+res2.getString("lastName");
 }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head> 
		<%@ include file="../master/head.jsp" %>
                 
		<script type="text/javascript" src="js/drag_drop_1.js"></script>
		<script type="text/javascript" src="js/project.js"></script>
		<link rel="STYLESHEET" href="styles/project.css" type="text/css">
		<link rel="stylesheet" href="styles/control_1.css" type="text/css"/>
		<script type="text/javascript">
                     var isThereIsChange = false;
function check() {
var it = new Array();
<%
        int i=0;
	for(;i<ids.length;i++)
	{
		out.println("it["+i+"] = document.getElementById('"+ids[i]+"');");
	}
        
                
%>
for(var i=0;i<it.length;i++)
{
	if(it[i] != null && it[i].parentNode.id == "DragContainer4")
	{
		document.getElementById("in"+i).value = "accepted";
	}
	else if(it[i] != null && it[i].parentNode.id == "DragContainer5")
	{
		document.getElementById("in"+i).value = "pending";
	}
        else if(it[i] != null && it[i].parentNode.id == "DragContainer6")
	{
		document.getElementById("in"+i).value = "dropped";
	}
	isThereIsChange = true;
        
}
var links = document.body.getElementsByTagName("a");
for(var i=0;i<links.length;i++)
{
    links[i].onclick = function() {
        return confirm("You made changes on users status\nDo you want to discard it? if you do not click save changes button");
    }
}
return true;
}
		</script>
		 <style>
			  .DragBox {
				   font-size:15px;
					font-weight: bold;
				   }
			  B.creat
			   {
									   font-size:12px;
					color: blue;
					 font-weight: normal;
				   }
			  B.proj
			   {
									   font-size:12px;
					color: red;
					 					 font-weight: normal;
				   }
					
		  </style>
	</head>
	<body>
		<div id="container">
			<div id="wrapper">
				<div id="sidebar">
					<div id="sb_top">
						<%@ include file="../master/sbTop.jsp" %>
					</div>
					
					<div class="sb_content">
						
						<!--##########-->
							<!-- Start Menu -->
							<%@ include file="../master/Profmenu.jsp" %>
							
							<!-- Profile -->
							<%@ include file="../master/profile.jsp" %>
							
							<!-- links -->
							<%@ include file="../master/links.jsp" %>
						<div class="copyright">
							<%@ include file="../master/copyright.jsp" %>
						</div>
						
					</div> <!-- /sb_content -->
				</div> <!-- /sidebar -->
					
					
				<!-- Top -->
				<div id="header">
					<%@ include file="../master/header.jsp" %>
				</div>
				
				
				<!-- Start main content -->
				<div id="content">
					<div id="intro">
						<div class="intro_t">
							<h1><span>..</span>Welcome to<span>..</span></h1>
							<h2 >student project managment system</h2>
							
						</div>
					</div> <!-- /intro -->
                                         <h1> Control Projects </h1>
<%
DBCon db = new DBCon();
String control = db.getControlValue("control_project");
            
if(control.equals("true"))
{
%>
                                         <TABLE BORDER="0" width="100%">
                                            <tr>
                                                <td><center><h2>Accepted Projects</h2></center></td>
                                                <td><center><h2>Pended Projects</h2></center></td>
                                                <td><center><h2>Rejected Projects</h2></center></td>
                                            </tr>
                                         </TABLE>
					<DIV id=Demo4 width="100%">
						<DIV class=DragContainer id=DragContainer4 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < ids.length; x++) {
                                     if(status[x].equals("accepted"))
                                         {
							%>
							 <DIV class=DragBox id="<%=ids[x]%>" overClass="DragBox" dragClass="DragBox" ondblclick="openWindow(<%=ids[x]%>)">
								  <%= titles[x] %><br><B class='creat'>created by:</B><b class = 'proj'><%=profName[x]%></b>
							   </DIV>
							<%
                                        }}
							%>
						</DIV>
						<DIV class=DragContainer id=DragContainer5 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < ids.length; x++) {
                                     if(status[x].equals("pending")){
							%>
							<DIV class=DragBox id="<%=ids[x]%>" overClass="DragBox" dragClass="DragBox" ondblclick="openWindow(<%=ids[x]%>)">
							 <%=titles[x]%><br><B class='creat'>created by:</B><b class = 'proj'><%=profName[x]%></b>
							  </DIV>
							<%
				    }}
							%>
						</DIV>
                                                 <DIV class=DragContainer id=DragContainer6 overClass="OverDragContainer">
							<%
                                for (int x = 0; x < ids.length; x++) {                        
				 if(status[x].equals("dropped")){
							%>
							 <DIV class=DragBox id="<%=ids[x]%>" overClass="DragBox" dragClass="DragBox" ondblclick="openWindow(<%=ids[x]%>)">
							  <%=titles[x]%><br><B class='creat'>created by:</B><b class = 'proj'><%=profName[x]%></b>
							   </DIV>
							<%
				    }}
							%>
						</DIV>
                                                 <form name="types" action="changeStatus.jsp" method="get">
						<%
                                                
                        int x=0;
			for(;x<ids.length;x++)
			{
				%>
				<input type="hidden" id="in<%=x%>" name="<%=ids[x]%>" value="<%=status[x]%>" />
				<%
			}%>
                          <center><input type="submit" value="save changes"></center>
                        <%}else{%>
<br/><br/><center><h2> This service is not availabe now </h2></center>
<%}
			}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
    //out.println(e);
}

                        %>
                        
                                                </form>
					</DIV>
                                         	
				</div> <!-- /content -->
				
			</div> <!-- /wrapper -->
			<div class="clear">&nbsp;</div> <!-- Important! Fix the problem of height in Firefox -->
		</div> <!-- /Container -->
			
		
	</body>
</html>